package com.jarveis.dbs.core;

import java.util.Hashtable;

import org.apache.log4j.Logger;

import com.jarveis.dbs.core.filter.Filter;

/**
 * @desc 过滤器工厂类
 * @author liuguojun
 * @create 2015-08-09
 */
public class FilterFactory {

	private static final Logger logger = Logger.getLogger(FilterFactory.class);

	private static Hashtable<String, Filter> filterStore = new Hashtable<String, Filter>();

	/**
	 * 添加Filter
	 * 
	 * @param id
	 *            过滤器标识
	 * @param filter
	 *            过滤器对象
	 */
	public static void put(String id, Filter filter) {
		filterStore.put(id, filter);
	}

	/**
	 * 获取Filter
	 * 
	 * @param id
	 *            过滤器标识
	 * @return Filter
	 * @see com.jarvice.dbs.filter.Filter
	 */
	public static Filter get(String id) {
		Filter filter = filterStore.get(id);

		if (filter == null) {
			logger.info("系统异常，过滤器不存在");
			return null;
		}

		return filter;
	}
}
